@extends('admin.main')

@section('body')
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>微信列表</h2>
    </div>
    <div class="cf">

        <!-- 高级搜索 -->
        <div class="search-form fr cf">
            <div class="sleft">
                <input type="text" name="keyword" class="search-input" value="{{request('keyword')}}"
                       placeholder="请输入昵称">
                <a class="sch-btn" href="javascript:;" id="search" url="{{urlAdmin('wechat','getIndex')}}"><i
                            class="btn-search"></i></a>
            </div>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
        <table class="">
            <thead>
            <tr>
                <th class="">ID</th>
                <th class="">昵称</th>
                <th class="">公众号ID</th>
                <th class="">公众号密钥</th>
                <th class="">商户号ID</th>
                <th class="">商户密钥</th>
                <th class="">小程序ID</th>
                <th class="">小程序密钥</th>
                <th class="">添加日期</th>
            </tr>
            </thead>
            <tbody>
            @if(count($rows['data']))
                @foreach($rows['data'] as $v)
                    <tr>
                        <td>{{$v['id']}}</td>
                        <td>{{$v['nickname']}}</td>
                        <td>@if($v['wx_app_id'])<span class="wx_list_yes">√</span>@else<span class="wx_list_no">×</span>@endif</td>
                        <td>@if($v['wx_app_secret'])<span class="wx_list_yes">√</span>@else<span class="wx_list_no">×</span>@endif</td>
                        <td>@if($v['mch_id'])<span class="wx_list_yes">√</span>@else<span class="wx_list_no">×</span>@endif</td>
                        <td>@if($v['mch_key'])<span class="wx_list_yes">√</span>@else<span class="wx_list_no">×</span>@endif</td>
                        <td>@if($v['xcx_app_id'])<span class="wx_list_yes">√</span>@else<span class="wx_list_no">×</span>@endif</td>
                        <td>@if($v['xcx_app_secret'])<span class="wx_list_yes">√</span>@else<span class="wx_list_no">×</span>@endif</td>
                        <td>{{$v['created_at']}}</td>
                    </tr>
                @endforeach
            @else
                <td colspan="12" class="text-center"> aOh! 暂时还没有内容!</td>
            @endif
            </tbody>
        </table>
    </div>
    <div class="page">
        @if($rows['last_page']>1)
            <div>
                @if($rows['prev_page_url'])
                    <a class="prev" href="{{$rows['prev_page_url']}}">&lt;&lt;</a>
                @endif
                @if(count($rows['pageNoList']))
                    @foreach($rows['pageNoList'] as $v)
                        @if($rows['current_page'] == $v)
                            <span class="current">{{$v}}</span>
                        @else
                            <a class="num" href="{{urlAdmin('wechat','getIndex',['page'=>$v])}}">{{$v}}</a>
                        @endif
                    @endforeach
                @endif
                @if($rows['next_page_url'])
                    <a class="next" href="{{$rows['next_page_url']}}">&gt;&gt;</a>
                @endif
                <span class="rows">共 {{$rows['total']}} 条记录</span>
            </div>
        @endif
    </div>
@endsection

@section('script')

    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
    </script>
@endsection
